package com.apexsoft.assets.base;

import com.apexsoft.aas.service.model.ARequest;
import com.apexsoft.assets.base.request.RequestInfoModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cglib.beans.BeanMap;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;

@Configuration
@EnableAsync
@Slf4j
/**
 * 异步方法抽出成单个类，以便spring生成代理
 */
public class AsyncConfig {

    @Async
    public void addsql2Log(RequestInfoModel resqInfo) {
        try{
            com.apexsoft.aas.service.model.ARequest aRequest = new ARequest();
            aRequest.setParams(BeanMap.create(resqInfo));
//            com.apexsoft.aas.service.model.AResponse result = AasCommService.sendRequest(
//                    Constants.NAMESAPCE_LOG, Constants.PKG_LOG, "log", aRequest);
        }catch (Exception e){
            log.warn("日志微服务异常");
        }
    }

    @Async
   public void addLog(RequestInfoModel resqInfo){
        try{
            ARequest aRequest = new ARequest();
            aRequest.setParams(BeanMap.create(resqInfo));
//            com.apexsoft.aas.service.model.AResponse aResponse = AasCommService.sendRequest(
//                    Constants.NAMESAPCE_LOG, Constants.PKG_LOG, "start", aRequest);
        }catch (Exception e){
            log.warn("日志微服务异常");
        }
    }
}
